package game.entity;

import java.util.ArrayList;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class SpriteManager{
	ArrayList<AbsSprite> listSprite;
	
	public SpriteManager() {
		listSprite = new ArrayList<AbsSprite>();
	}
	
	public void render(SpriteBatch sb){
		for(int i = 0; i<listSprite.size(); i++){
			listSprite.get(i).render(sb);
		}
	}
	public void renderShaper(){
		for(int i=0; i<listSprite.size(); i++){
			listSprite.get(i).renderShape();
		}
	}
	
	public void update(){
		for(int i = 0; i<listSprite.size(); i++){
			listSprite.get(i).update();
		}
	}
	
	public void add(AbsSprite sprite)
	{
		listSprite.add(sprite);
	}
	
	public void remove(int index){
		if(index < listSprite.size())
			listSprite.remove(index);
	}
	
	public AbsSprite getByID(int id)
	{
		for (AbsSprite sprite : listSprite) {
			if(sprite.getID() == id)
				return sprite;
		}
		return null;
	}
	
	public AbsSprite getByIndex(int index)
	{
		return listSprite.get(index);
	}

	public int count() {
		return listSprite.size();
	}
}
